package com.dc.designPattern._1_singleton.impl.type7;

/**
 * Description: 使用枚举，可以实现单例, 推荐
 * @author: gdc
 * @date: 2020/12/26
 * @version 1.0
 */
enum Singleton {
	//属性
	INSTANCE;

	public void sayOK() {
		System.out.println("ok~");
	}
}

public class SingletonTest07 {
	public static void main(String[] args) {
		Singleton instance = Singleton.INSTANCE;
		Singleton instance2 = Singleton.INSTANCE;
		System.out.println(instance == instance2);

		System.out.println(instance.hashCode());
		System.out.println(instance2.hashCode());

		instance.sayOK();
	}
}

